func findAnagrams(s string, p string) []int {
    lenP, lenS := len(p), len(s)
    ans := []int{}
    if lenP > lenS {
        return ans
    }

    p_counts := [26]int{}
    for _, ch := range p {
        p_counts[ch-'a']++
    }

    left := 0
    s_counts := [26]int{}
    for right := 0; right < lenS; right++ {
        ch := s[right] - 'a'
        s_counts[ch]++

        for s_counts[ch] > p_counts[ch] {
            left_ch := s[left] - 'a'
            s_counts[left_ch]--
            left ++
        }

        if right - left + 1 == lenP {
            ans = append(ans, left)
        }
    }
    return ans
}